package com.zzf.concurrent.example.design.pattern.active.object;

import com.zzf.concurrent.example.util.TimeUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * 异步方法的具体实现类
 * @author GaoFeng2017
 * @date 2019/9/11 14:01
 */
@Slf4j
class Servant implements ActiveObject {

    @Override
    public Result makeString(int count, char ch) {
        char[] chs = new char[count];
        Arrays.fill(chs, ch);
        TimeUtil.sleep((long) (Math.random() * count * 20));
        return new RealResult(new String(chs));
    }

    @Override
    public void printString(String text) {
        log.info("result is {}", text);
    }

}
